/*
 * Zehra Syed
 */

#ifndef QUEUE_H_
#define QUEUE_H_

#include <pthread.h> // For mutex access.
#include <stdio.h>   // For q_print (to print to console).
#include <stdlib.h>  // For NULL


// Mutexes for preventing race conditions on the individual queues.
pthread_mutex_t * queue_mutex;

// Node. Building block of linked list. Used by all queues.
typedef struct Node {
	int pid;
	struct Node * next;
} Node;

// Enum for different types of queues.
typedef enum queue_enum {
	IO_KEYBOARD_QUEUE,
	IO_DISK_QUEUE,
	IO_VIDEO_QUEUE,
	INTERRUPT_QUEUE,
	SEM_BLOCKED_QUEUE,
	READY_QUEUE
} QUEUE;

// Pointers to head of each queue.
Node * io_kb_queue;
Node * io_disk_queue;
Node * io_video_queue;
Node * interrupt_queue;

// Initializes queues.
void q_initialize();

// Helper methods for handling multiple queues
Node * q_get(QUEUE);
void q_set_head(QUEUE, Node*);
int q_get_mutex(QUEUE);

// Methods for modifying the queue.
void q_add(QUEUE, int);
void q_print(QUEUE);
int q_remove(QUEUE);
int q_is_empty(QUEUE);

#endif
